package com.wonders.frame.controller;

import com.gcr.server.response.Response;
import com.wonders.frame.common.Enum.InitCommonSourceEnum;
import com.wonders.frame.controller.core.CoreController;
import com.wonders.frame.entity.HuiAreas;
import com.wonders.frame.entity.Tree.AreasNodeData;
import com.wonders.frame.service.Core.CoreCurdService;
import com.wonders.frame.service.HuiAreasService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/huiAreas")
public class HuiAreasController extends CoreController<HuiAreas> {

    @Autowired
    private HuiAreasService service;

    @Override
    protected CoreCurdService getService() {
        return service;
    }

    @RequestMapping("/getAreasTree")
    public Response getAreasTree(){
        try {
            List<AreasNodeData> list = InitCommonSourceEnum.INSTANCE.getAreas();
            return successResponse(list);
        } catch (Exception e) {
            e.printStackTrace();
            return errorResponse();
        }

    }

}
